import { baseUrl } from './config.js'

export function topList() {
	// 为了获取榜单详情需要传入榜单 id
	// let listIds = ['19723756', '3779629', '2884035', '3778678'];
	
	// 获取榜单
	return new Promise(function (reslove, reject) {
		uni.request({
			url: `${baseUrl}/toplist/detail`,
			method: 'GET',
			data: {},
			success: res => {
				let result = res.data.list;
				result.length = 4;
				// for(let i = 0; i < 4; i++) {
				// 	result[i].listId = listIds[i];
				// }
				reslove(result);
			},
			fail: () => {},
			complete: () => {}
		});
	});
}

// 获取榜单歌曲详情
export function list(listId) {
	return uni.request({
		url: `${baseUrl}/top/list?id=${listId}`,
		method: 'GET'
	});
}

// yum install -y wget && wget -O install.sh http://download.bt.cn/install/install_6.0.sh && sh install.sh
// 获取歌曲详情
export function songDetail(songId) {
	return uni.request({
		url: `${baseUrl}/song/detail?ids=${songId}`,
		// url: `https://y.music.163.com/m/song?id=${songId}`,
		method: 'GET'
	});
}

// 获取相似歌曲
export function songSimi(songId) {
	return uni.request({
		url: `${baseUrl}/simi/song?id=${songId}`,
		method: 'GET'
	});
}

// 获取评论
export function songComment(songId) {
	return uni.request({
		url: `${baseUrl}/comment/music?id=${songId}`,
		method: 'GET'
	});
}

// 获取歌词
export function songLyric(songId) {
	return uni.request({
		url: `${baseUrl}/lyric?id=${songId}`,
		method: 'GET'
	});
}

// 获取歌曲 url
export function songUrl(songId) {
	return uni.request({
		url: `${baseUrl}/song/url?id=${songId}`,
		method: 'GET'
	});
}

// 获取热词
export function searchHot() {
	return uni.request({
		url: `${baseUrl}/search/hot/detail`,
		method: 'GET'
	});
}
// 获取搜索结果
export function searchWord(word) {
	return uni.request({
		url: `${baseUrl}/search?keywords=${word}`,
		method: 'GET'
	});
}
// 搜索提示文字
export function searchSuggest(word) {
	return uni.request({
		url: `${baseUrl}/search/suggest?keywords=${word}&type=mobile`,
		method: 'GET'
	});
}
